<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>grid</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        
        ul {
            display: grid;
            /* 设置列宽 */
            grid-template-columns: repeat(auto-fill, 200px);
            /* 设置间距*/
            grid-gap: 1rem;
        }
        
        li {
            height: 50px;
            background-color: #eee;
            box-shadow: 0 0 3px gray;
            font-size: 3rem;
            text-align: center;
            line-height: 50px;
        }
    </style>
</head>

<body>
    <ul>
        <li>item1</li>
        <li>item2</li>
        <li>item3</li>
        <li>item4</li>
        <li>item5</li>
        <li>item6</li>
        <li>item7</li>
        <li>item8</li>
        <li>item9</li>
    </ul>
</body>

</html>